package com.qxp.simplerpc;

import com.qxp.simplerpc.annotation.EnableSimpleRpcAutoConfig;
import com.qxp.simplerpc.annotation.Service;
import com.qxp.simplerpc.registry.Register;
import com.qxp.simplerpc.server.RpcServer;
import com.qxp.simplerpc.server.RpcServerHandler;
import com.qxp.simplerpc.server.RpcServerInvoker;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnBean(annotation= EnableSimpleRpcAutoConfig.class)
@ConditionalOnClass(value = Service.class)
@AutoConfigureAfter(AutoConfiguration.class)
@ConditionalOnProperty(prefix = "spring.simplerpc",value="server")
public class ProviderAutoConfiguration extends CommonAutoConfiguration {
    @Bean
    public Register getServerRegister(){
        return new Register();
    }
    @Bean
    public RpcServer getRpcServer(){
        return new RpcServer();
    }
    @Bean
    public RpcServerHandler getRpcServerHandler(){
        return new RpcServerHandler();
    }
    @Bean
    public RpcServerInvoker getRpcServerInvoker(){return new RpcServerInvoker();}


}
